#!/bin/bash
sudo kill -9 $(lsof -i:5000 -t) &>/dev/null
while getopts l:k option
do 
    case "$option" in
        l)
            p=$OPTARG
	    ;;
        \?)
            echo "option error"
            exit 1;;
    esac
done
if [ "$p" = "true" ]; then
    python3 -u main.py > applog.log 2>&1 &
    echo "running webapp in background sucess! and log infro will be saved in applog.log"
elif [ "$p" = "false" ]; then
    python3 main.py
elif [ "$p" = "kill" ]; then
    sudo kill -9 $(lsof -i:5000 -t) &>/dev/null
else
    echo "pls input true for logging in a file, false for logging in shell, kill for kill teh running web app"
fi
